package com.yanqu.road.server.cmd.activity.newyear2023.redpacket.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FireWorkProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_FIREWORK_CROSS_DATA_SYNC, desc = "用户数据同步")
public class CrossFireWorkSyncUserDataCmd extends AbstractCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        FireWorkProto.FireWorkCrossDataSyncMsg reqMsg = FireWorkProto.FireWorkCrossDataSyncMsg.parseFrom(packet.getBytes());
        GamePlayer player = GamePlayerMgr.getOnlinePlayer(packet.getPlayerId());
        if(player != null){
            FireWorkProto.FireWorkCrossDataSyncMsg.Builder syncMsg = FireWorkProto.FireWorkCrossDataSyncMsg.newBuilder();
            syncMsg.setActivityId(reqMsg.getActivityId());
            syncMsg.setOpenStatusNum(reqMsg.getOpenStatusNum());
            syncMsg.setOpenHistoryCount(reqMsg.getOpenHistoryCount());
            syncMsg.setCanRob(reqMsg.getCanRob());
            player.sendPacket(Protocol.U_FIREWORK_CROSS_DATA_SYNC, syncMsg);
        }
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
